/* eslint-disable react/jsx-pascal-case */
import React, { useState, useRef } from 'react';
import Counter from "./Count";

function Example4() {
  const [count, setCount] = useState(0);
  const childRef = useRef(null)
  const handleGetChildData = () => {
    const data = childRef.current.getFromData()
    console.log('data', data)
  }
  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => { setCount(count + 1) }}>click me</button>
      <Counter data={count} ref={childRef}></Counter>
      <button onClick={() => handleGetChildData()}>我要获取子组件的数据</button>
    </div>
  )
}
export default Example4;